<?php
class account extends AppModel
{
    public $useTable = 'account';

    public function get_user_count($_game_name)
    {
        $this->useDbConfig = $_game_name;
        return $this->find('count');
    }

    public function get_push_id($_usn, $_game_name)
    {
        $this->useDbConfig = $_game_name;
        $params = array(
            'fields' => array('usn', 'push_id', 'os'),
            'conditions' => array(
                'usn' => $_usn,
            ),
        );

        $data = $this->find('first', $params);
        $data['account']['push_id'] = array($data['account']['push_id']);

        return $data['account'];
    }

    public function get_push_id_list($_start_limit, $_end_limit, $_game_name)
    {
        $this->useDbConfig = $_game_name;
        $data = $this->query("SELECT usn, push_id, os FROM account LIMIT $_start_limit, $_end_limit");
        $push = array();

        foreach($data as $list)
        {
            if(!empty($list['account']['push_id']))
            {
                $push[] = array(
                    'usn' => $list['account']['usn'],
                    'push_id' => $list['account']['push_id'],
                    'os' => $list['account']['os'],
                );
            }
        }

        return $push;
    }
}